{% extends "default.html" %}
{% load i18n %}

{% block custom_styles %}
	{{ block.super }}
	<link rel="Stylesheet" type="text/css" href="/static/styles/jqueryui/base/jquery.ui.all.css" />
{% endblock custom_styles %}

{% block custom_scripts %}
	<script type="text/javascript" src="/static/js/jquery-ui-1.8.6.custom.min.js"></script>
{% endblock custom_scripts %}

{% block title %}
{% if update %}
{% trans "Edit" %} {% trans "Ad" %}
{% else %}
{% trans "Register New Ad" %}
{% endif %} 
{% endblock %}

{% block page_title %}
{% if update %}
{% trans "Edit" %} {% trans "Ad" %}
{% else %}
{% trans "Register New Ad" %}
{% endif %} 
{% endblock %}

{% block page_content %}

<div class="box">
			
	<div class="notop">
		<div class="left"></div>
		<div class="right"></div>
		<div class="center"></div>
	</div>
	
	<div class="middle">
		
		{% if error %}
		<div style="color: red;">
		{{ error }}
		</div>
		{% endif %}
		
		<form
			{% if update %} 
			action="/ads/update/{{ object_id }}/" 
			{% else %}
			action="/ads/register/" 
			{% endif %}
			method="post">
		
		{% for field in form %}
			<div class="form_field_wrapper">
				{% if field.errors %}
				<div class="form_field_error">{{ field.errors }}</div>
				{% endif %}
				<div class="form_field">
					<div class="form_field_label">
						<label>{{ field.label_tag }}:</label>
					</div>
					<div class="form_field_input">
						{{ field }}
					</div> 
					<br class="clear" />
				</div>
			</div>
		{% endfor %}
			<br class="clear"/>
			<div class="form_buttons">
				<input type="submit" value='{% trans "Save" %}' class="form_button" />
			</div>
		</form>
		<script type="text/javascript">
		$("#id_url").change(function() {
			var v = $("#id_url").attr('value');
			if (v != "") {
				if (v.indexOf('http') == -1) {
					$("#id_url").attr('value', "http://" + v);
				}
			}
		});
		</script>
		
		
		
	</div>
	
	<div class="bottom">
		<div class="left"></div><div class="right"></div><div class="center"></div>
	</div>
</div>


{% endblock page_content %}
